package com.example.hf_v1.controller;

import com.example.hf_v1.config.Result;
import com.example.hf_v1.entity.Hairstyles;
import com.example.hf_v1.service.HairstylesService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/hairstyles")
public class HairstylesController {
    @Resource
    private HairstylesService hairstyleService;

    //增加发型
    @RequestMapping("/addHairstyle")
    public Result addHairstyle(@RequestBody Hairstyles hairstyle) {
       return Result.success(hairstyleService.save(hairstyle));
    }

    //删除发型
    @RequestMapping("/deleteHairstyle")
    public Result deleteHairstyle(Integer id) {
        return Result.success(hairstyleService.removeById(id));
    }

    //修改发型
    @RequestMapping("/updateHairstyle")
    public Result updateHairstyle(@RequestBody Hairstyles hairstyle) {
        return Result.success(hairstyleService.updateById(hairstyle));
    }

    //查询所有发型
    @RequestMapping("/selectAllHairstyles")
    public Result selectAllHairstyles() {
        return Result.success(hairstyleService.selectAllHairstyles());
    }

    //模糊查询发型名称
    @RequestMapping("/selectHairstyleByName")
    public Result selectHairstyleByName(String name) {
        return Result.success(hairstyleService.selectHairstyleByName(name));
    }

    //按类型查询发型（两表联查）
    @RequestMapping("/selectHairstyleByType")
        public Result selectHairstylesByType(String type) {
        return Result.success(hairstyleService.selectAllHairstylesByType(type));
    }

    //按照脸型查询
    @RequestMapping("/selectHairstyleByFace")
    public Result selectHairstyleByFace(String faceType){
        return Result.success(hairstyleService.selectHairstyleByFace(faceType));
    }
}
